#ifndef STM32F103VET6_PROJECT_SYS_CORE_CONF_H
#define STM32F103VET6_PROJECT_SYS_CORE_CONF_H
#define HAL_TIM_MODULE_ENABLED


#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>

#define SIZE_8B (8)
#define SIZE_256B (256)
#define SIZE_512B (512)
#define SIZE_1K   (1024)
#define SIZE_2K   (2048)
#define SIZE_3K   (3072)
#define SIZE_4K   (4092)

#define U8_MAX     ((u8)255)
#define S8_MAX     ((s8)127)
#define S8_MIN     ((s8)-128)
#define U16_MAX    ((u16)65535u)
#define S16_MAX    ((s16)32767)
#define S16_MIN    ((s16)-32768)
#define U32_MAX    ((u32)4294967295uL)
#define S32_MAX    ((s32)2147483647)
#define S32_MIN    ((s32)-2147483648)
/**
 * @brief 日志缓存大小
 */
#define LOG_BUFFER_SIZE 512





typedef enum {
    core_status_ok = 0x0,  /**< Indicates no error occurred */
    // GENERIC ERRORS 0x0000 .. 0x00F0
    ERROR_DEVICE_DRIVER = 0x4,    /**< 设备驱动错误 */
    ERROR_DEVICE_NOT_INITIALISED = 0x5,  /**< 设备未初始化 */

    // GENERIC ERRORS 0x00F0 .. 0x00FF  (数据校验错误)
    ERROR_INVALID_PARAMETER = 0xF1,  /**< 非法参数 */

    // I2C ERRORS  0x0100 .. 0x010F
    ERROR_I2C_DEVICE_NOTFOUND = 0x101,  /**< Device didn't ACK after an I2C transfer */
    ERROR_I2C_NOT_ACK = 0x102,  /**< No ACK signal received during an I2C transfer */
    ERROR_I2C_TIMEOUT = 0x103,  /**< Device timed out waiting for response (missing pullups?) */
    // SPI ERRORS  0x0110 .. 0x011F
    ERROR_SPI_TIMEOUT = 0x111,  /**TIMEOUT */
    ERROR_SPI_BUSY = 0x112,  /**BUSY */

    // FLASH ERRORS  0x0120 .. 0x012F
    ERROR_FLASH_DATA = 0x0121, /** Flash 数据错误*/
    ERROR_FLASH_READ_FAILED = 0x0122, /** Flash 读失败*/
    ERROR_FLASH_WRITE_FAILED = 0x0123, /** Flash 写失败*/
} common_error_t;
typedef struct {
    // 执行之前
    void (*invoke_before)(void);

    // 执行
    void (*invoke)(void);

    // 执行之后
    void (*invoke_after)(void);
} sys_core_invoke_t;
/**
 * sec_name: section标签名：唯一值
 * before: 执行之前
 * exec: 执行
 * after: 执行之后
 */
#define SYS_EXPORT(sec_name, tag, before, exec, after) sys_used const  sys_core_invoke_t __fn_##tag sys_section(sec_name) = {before,exec,after}
#endif //STM32F103VET6_PROJECT_SYS_CORE_CONF_H
